#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<stdlib.h>
using namespace std;
int main(){
	ifstream ifs("d:\\scada.txt");
	string dd[96][88];
	int i=0;
	int j=0;
	for(i=0;i<96;i++){
		for(j=0;i<88;j++){
			getline(ifs,dd[i][j],',');
		}
	}
	float psum[96];
	float qsum[96];
	string data[96];
	string time[96];
	float Psum=0.0;
	float Qsum=0.0;
	int l,m,n,s;
	float pmax=0.0;
	float pmin=0.0;
	float pavg=0.0;
	float qavg=0.0;
	float qmax=0.0;
	float qmin=0.0;
	double psum1[96];
	double qsum1[96];
	double Psum1=0.0;
	double Qsum1=0.0;
	double pmax1=0.0;
	double pmin1=0.0;
	double pavg1=0.0;
	double qavg1=0.0;
	double qmax1=0.0;
	double qmin1=0.0;
	for(int k=0;k<96;k++){
		stringstream ss1(dd[k][2]);
		ss1>>psum[i];
		ss1>>psum1[i];
		Psum+=psum[i];
		Psum1+=psum1[i];
		stringstream ss2(dd[k][3]);
		ss2>>qsum[i];
		Qsum+=qsum[i];
		ss2>>qsum1[i];
		Qsum1+=qsum1[i];
		stringstream ss3(dd[k][0]);
		ss3>>data[i];
		stringstream ss4(dd[k][1]);
		ss4>>time[i];
		if((psum[i]>pmax)||(psum1[i]>pmax1)){
			pmax=psum[i];
			pmax1=psum1[i];
			l=i;
		}
		if((qsum[i]>qmax)||(qsum1[i]>qmax1)){
			qmax=qsum[i];
			qmax1=qsum1[i];
			m=i;
		}
		if((psum[i]<pmin)||(psum1[i]<pmin1)){
			pmin=psum[i];
			pmin1=psum1[i];
			n=i;
		}
		if((qsum[i]<qmin)||(qsum1[i]<qmin1)){
			qmin=qsum[i];
			qmin1=qsum1[i];
			s=i;
		}
	}
		pavg=Psum/96.0;
		qavg=Qsum/96.0;
		pavg1=Psum1/96.0;
		qavg1=Qsum1/96.0;
		cout<<"总有功最大值时间："<<dd[l][1]<<"总有功最大值:"<<pmax<<endl;
		cout<<"总有功最小值时间："<<dd[n][1]<<"总有功最小值:"<<pmin<<endl;
		cout<<"总无功最大值时间："<<dd[m][1]<<"总无功最大值:"<<qmax<<endl;
		cout<<"总无功最小值时间："<<dd[s][1]<<"总无功最小值:"<<qmin<<endl;
		cout<<"总有功平均值(float)"<<pavg<<endl;
		cout<<"总无功平均值(float)"<<qavg<<endl;
		cout<<"总有功平均值(double)"<<pavg1<<endl;
		cout<<"总无功平均值(double)"<<qavg1<<endl;
	return 0;
}

